<?php

namespace app\queue\redis;

use app\services\UserLevelService;
use Webman\RedisQueue\Consumer;

class LevelCheck implements Consumer
{
    public $queue = 'level-check';

    public $connection = 'default';

    public function consume($data)
    {
        $nextLevel = UserLevelService::levelUpCheck($data['user_id']);

        if ($nextLevel) {
            UserLevelService::levelUp($data['user_id'], $nextLevel);
        }
    }
}